package WordCount;

import java.io.IOException;
import java.util.*;
import java.util.Map.Entry;

public class Main {
	public static void main(String[] args) throws IOException
	{
		
		/*String str = of.readFile();*/
	
	//	String str=sc.nextLine();
		Scanner sc =new Scanner(System.in);	
		String file = sc.next();
		OperateFile fd = new OperateFile();
		String str = fd.FileToString(file);//读出文件内容变成字符串
		Word wd = new Word(str);
		
		int charNum = wd.getcharNum();//字符数
		int wordNum = wd.getwordNum();//单词数
		int lineNum = wd.getlineNum();//有效行
		List<Map.Entry<String, Integer>> wordFreq = wd.getwordFreq();//单词频率
		System.out.print(wordFreq);
		
		String w = "characters:"+charNum + "\r\n" + "words:"+wordNum + "\r\n" +"lines:"+ lineNum + "\r\n\r\n";
		for (Entry<String, Integer> mapping : wordFreq) {  //输出
			w = w + mapping + "\r\n";
        } 
		System.out.println(w);
		fd.WriteToFile(w);
		
	//	of.writeFile();	
		
	}
}
